<template>
	<view>
		<page-nav></page-nav>
		<view class="u-page min-h75">
			<view class="btn-list">
				<button data-eventsync="true" type="primary" @click="toPage('/pages/behavior/index')">违法行为速查</button>
				<button data-eventsync="true" type="primary" @click="toPage('/pages/template/template')">执法文书模板</button>
				<button data-eventsync="true" type="primary" @click="toMiniProgram('wx47bd0467e2a74547')">法律法规</button>
				<button data-eventsync="true" type="primary" disabled="true">典型案例</button>
				<button data-eventsync="true" type="primary" disabled="true">监管实务</button>
				<button data-eventsync="true" type="primary" @click="toPage('/pages/test/test')" >test</button>
			</view>
		</view>
		<xasa-foot></xasa-foot>
	</view>
	<u-loading-page loading-color="#00cccc" loading-mode="spinner" bg-color="rgba(255, 255, 255, 0.8)"
		:loading="!isReady" icon-size="72" loading-text="loading..."></u-loading-page>
</template>
<script>
	const db = uniCloud.databaseForJQL();
	export default {
		data() {
			return {
				loadthen: new Promise(() => {}),
				isReady: false // 是否正在加载中
			}
		},
		methods: {
			toPage(url) {
				uni.navigateTo({
					url: url
				})
			},
			toMiniProgram(appId) {
				// #ifdef MP
				uni.navigateToMiniProgram({
					appId: appId
				})
				// #endif
			}
		},
		async onLoad() {
			this.loadthen = db.collection('xasa-global').get({
				getOne: true
			});
			const res = await this.loadthen; // 等待获取云存储域名。
			if (res.errCode === 0) {
				uni.setStorageSync("downloadUrl", res.data.downloadurl);
				setTimeout(() => {
					this.isReady = true
				}, 100)
			} else {
				uni.showToast({
					title: "network error!",
					duration: 5000
				})
			}
		},
		onShow() {},
		onReady() {}
	}
</script>

<style lang="scss">
	.content {
		padding-bottom: 30px;
	}

	.title {
		font-weight: bold;
		text-align: center;
		padding: 20px 0px;
		font-size: 20px;
	}

	.tips {
		color: #999999;
		font-size: 14px;
		padding: 20px 30px;
	}

	.btn-list {
		padding: 0px 30px;
	}

	.btn-list button {
		margin-bottom: 20px;
	}

	.upload-preview {
		width: 100%;
	}
</style>